/*
 * @Author: your name
 * @Date: 2021-12-30 16:53:06
 * @LastEditTime: 2021-12-31 17:20:04
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \Sxun\briup-wisdom-order\src\store\address\address.js
 */
import { get, post } from "@/http/axios";
export default {
  namespaced: true,
  // 保存要使用的数据
  state: {
    addressData: [],
    comsume:[],
  },
  mutations: {
    SET_AddressData(state, addressData) {
      state.addressData = addressData
    },
    set_comsume(state, data){
      state.comsume = data;
    }
  },
  actions: {
 // 获取地址列表
    async getAddressData({ commit }, userId) {
      let res = await get('/app/address/queryByUserId?userId='+ userId)
      commit('SET_AddressData', res.data.data)
      // console.log(res.data.data);
    },
     // 新增地址
    async saveOrUpdateAddress({commit}, params){
      let res = await post('/app/address/saveOrUpdate', params)
      // console.log(res);
      return res
    },
    // 删除地址
    async deleteAddressById({ commit }, addressId){
      
    },
    // 订单消费记录
    async getComsume({commit}, params){
      let res = await get('/account/pageQueryCustomerAccount', params);
      commit('set_comsume', res.data.data.list)
    }
  },
};